﻿using System.ComponentModel.DataAnnotations.Schema;
using Flagwind.Database.Builder.Models.Users;
using System.Data.Entity.ModelConfiguration;

namespace Flagwind.Database.Builder.Mappings
{
    public class UserMapping : EntityTypeConfiguration<User>
    {
        public UserMapping(string schema = "dbo")
        {
            this.ToTable(schema + ".User");

            this.HasKey(x => x.UserId);

            this.Property(x => x.UserId).HasColumnName("UserId").IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(x => x.Username).HasColumnName("Username").IsRequired().IsUnicode(true).HasMaxLength(50);
            this.Property(x => x.Password).HasColumnName("Password").IsOptional().IsUnicode(false).HasMaxLength(50);
            this.Property(x => x.Name).HasColumnName("Name").IsOptional().IsUnicode(true).HasMaxLength(20);
            this.Property(x => x.Gender).HasColumnName("Gender").IsOptional();
            this.Property(x => x.Mobile).HasColumnName("Mobile").IsOptional().IsUnicode(false).HasMaxLength(11);
            this.Property(x => x.Email).HasColumnName("Email").IsOptional().IsUnicode(false).HasMaxLength(50);
            this.Property(x => x.Avatar).HasColumnName("Avatar").IsOptional().IsUnicode(false).HasMaxLength(100);
            this.Property(x => x.Remark).HasColumnName("Remark").IsOptional().IsUnicode(true).HasMaxLength(500);
            this.Property(x => x.Status).HasColumnName("Status").IsRequired();
            this.Property(x => x.CreatedTime).HasColumnName("CreatedTime").IsRequired();
        }
    }
}